package com.example.weektwo.dailysupplies.two;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.weektwo.Bean.ContentDatas;
import com.example.weektwo.Bean.InfoBean;
import com.example.weektwo.R;
import com.example.weektwo.dailysupplies.Three.ShoppingCartActivity;

import java.util.List;

public class ChoiceActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "ChoiceActivity";
    TextView tv_title;
    ImageView iv_back,iv_goshop;
    ListView choiceLv;
    private ChoiceAdapter adapter;
    private int pos;
    private List<List<InfoBean>> allList;
    private List<InfoBean> beanList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choice);
        tv_title = findViewById(R.id.top_tv);
        iv_back = findViewById(R.id.top_iv);
        iv_goshop=findViewById(R.id.shopcar_goshop);
        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        pos = getIntent().getIntExtra("pos",0);
        allList = ContentDatas.getAllList();   //全部数据源
//       ListView 数据源
        beanList = allList.get(pos);
        tv_title.setText(name);
        iv_back.setOnClickListener(this);
        iv_goshop.setOnClickListener(this);
        choiceLv=findViewById(R.id.choice_lv);
        adapter = new ChoiceAdapter(this, beanList);
        choiceLv.setAdapter(adapter);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.top_iv:
                finish();
                break;
            case R.id.shopcar_goshop:
                Intent intent = new Intent(this, ShoppingCartActivity.class);
                startActivity(intent);
        }
    }
}
